<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html>
  <head>
  <base target="_self"/>
  
  <title>复制表添加页面</title>
  	<meta http-equiv="X-UA-Compatible" content="IE=7" />
  	<%@ include file="../jslib/jquerylib.jsp" %>
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
    <script type="text/javascript">
    //var api = frameElement.api, W = api.opener;
    $().ready(function() {
		var api = frameElement.api, W = api.opener;
    	// 准备好Options对象
    	var options = {
    	    url:'<%=request.getContextPath() %>/getAutoFormInfoNew!insertTable.action',
    	    beforeSubmit: checkForm,
    	    dataType:'json',
    	    success: function(data) {
    	     if(data.result=='success'){
		      		alert("复制成功！");  
		      		W.refreshIt();
		      		api.close();  
		      	}else if(data.result=='existsTbale'){
		      		alert("此表单英文名称已经存在！");
		      	}else{
		      		alert("系统繁忙，请您稍后再试！");
		      	}
    	}};
    	
		$('#saveBtn').click(function(){
			$('#pageFrom').ajaxSubmit(options);
			return false;
		});
		
		$('#closeBtn').click(function(){
			api.close();
		});
	});
	function checkForm(){
		//var flag = true;
		 var myPattern = new RegExp("^[a-zA-Z]");
		if($.trim($("#tableCnName").val()) == ""){
			alert("请填写表单中文名称!");
			$("#tableCnName").focus();
			return false;
		}else if(!checkExp($("#tableCnName").val())){
			alert("表单中文名称不能含有除_以外的特殊符号!");
			$("#tableCnName").focus();
			return false;
		}
		if($.trim($("#tableName").val()) == ""){
			alert("请填写表单英文名称!");
			$("#tableName").focus();
			return false;
		}else if(!myPattern.exec($("#tableName").val())) {
   	       alert("表单英文名称必须以字母开头!");
   	       $("#tableName").focus();
   	       return false;
	   	}else if(!checkExp($("#tableName").val())){
			alert("表单英文名称不能含有除_以外的特殊符号!");
			$("#tableName").focus();
			return false;
		}
	}
    //验证特殊字符
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		//var regEx = new RegExp(/^(([^$,"'#{\\])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
		return false;
		}
		return true;
	} 
</script>
 <style type="text/css">
	body{
		background:#ffffff; background-image:url(images/);
	}
	.tab_input{border: 1px solid #999;padding: 5px;width: 250px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
</style>
</head>
<body>
  	<form action="<%=request.getContextPath() %>/auto!saveForm.action" id="pageFrom" name="pageFrom" method="post">
  		<table width="100%" border="0" align="center" >
  		<input type="hidden" id="formId" name="formId" value="<%=request.getParameter("formId") %>"/>
  		<input type="hidden" id="formEnName" name="formEnName" value="<%=request.getParameter("formEnName") %>"/>
  			<tr>
			    <td align="right">中文名称：</td>
			    <td>
			    	<div class="div">
						<input id="tableCnName" name="tableCnName" style="width: 250px;" maxlength="20"/>
					</div>	
			    </td>
			</tr>
  			<tr>
			    <td align="right">英文名称：</td>
			    <td>
			    	<div class="div">
						<input id="tableName" name="tableName" style="width: 250px;" maxlength="20"/>注:表名不能超过20字
					</div>	
			    </td>
			</tr>
		</table>
		<table width="100%" border="0" align="center" class="formTableNew">
			<td align="center">
		    	<input id="saveBtn" type="button" value="提 交" class="form_bt_orange" />
		      	<input type="button" id="closeBtn" value="取 消" onclick="close()" class="form_bt_grey" />
		    </td>
		</table>
	</form>
  </body>
</html>
